package com.learner.major.controller;


import com.learner.major.service.MajorService;
import com.learner.pojo.major.Major;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ice2020x
 * @Date: 2023/3/7
 * @Description: 专业信息的控制器
 **/
@RestController
@RequestMapping("/api/major/content")
public class MajorInfController {

    @Autowired
    MajorService majorService;

    /**
     * 专业信息更新
     *
     * @param majorInfo 专业信息
     * @return 列表
     */
    @PutMapping("/update")
    public Major updateMajor(@RequestBody Major majorInfo) {
        return majorService.updateUser(majorInfo);
    }


    /**
     * 添加专业信息
     *
     * @param major 专业信息
     * @return major
     */
    @PostMapping("/add")
    public Major insertMajor(@RequestBody Major major) {
        return majorService.addMajorInf(major);
    }

    /**
     * 查找专业信息列表
     *
     * @return 列表
     */
    @GetMapping("/list")
    public List<Major> selectAll() {
        return majorService.selectAll();
    }

    /**
     * @Description: id查找专业信息
     * @author: fgcy
     * @Params:
     * @since JDK 1.8
     */

    @GetMapping("/select/{id}")
    public Major selectById(@PathVariable("id") String id) {
        return majorService.selectById(id);
    }


    /**
     * 模糊查询
     *
     * @param majorName 专业名称
     * @return 列表
     */
    @GetMapping("selectLikely/{majorName}")
    public List<Major> selectMajorByLikelyNme(@PathVariable("majorName") String majorName) {
        return majorService.findByLikelyName(majorName);
    }


}
